
<!--_meta 作为公共模版分离出去-->
{include file="public/_meta"}

<style>
	.Hui-iconfont{position: relative;top: 5px;left: -40px;cursor:pointer;display: none;height: 5px}
</style>
<article class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form-member-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>头像：</label>
			<div class="formControls col-xs-7 col-sm-8 skin-minimal">
				<div style="width: 100%;position: relative;">
					<div id="upBox">
						<div id="inputBox" class="inputBox btn btn-primary radius">
							<input name="user_images" type="file" title="请选择图片" id="file" class="valid" />点击选择图片
						</div>
						<div id="imgBox"></div>
					</div>
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名：</label>
			<div class="formControls col-xs-7 col-sm-8">
				<input type="text" class="input-text" value="" placeholder="" id="username" name="username">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>姓名：</label>
			<div class="formControls col-xs-7 col-sm-8">
				<input type="text" class="input-text" value="" placeholder="" id="full_name" name="full_name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
			<div class="formControls col-xs-7 col-sm-8">
				<input type="text" class="input-text" value="" placeholder="" id="tel" name="tel">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>昵称：</label>
			<div class="formControls col-xs-7 col-sm-8">
				<input type="text" class="input-text" value="" placeholder="" id="nickname" name="nickname">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码：</label>
			<div class="formControls col-xs-7 col-sm-8">
				<input type="password" class="input-text password " value="" placeholder="" id="password" name="password">
			</div>
			<i class="Hui-iconfont">&#xe725;</i>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
			<div class="formControls col-xs-7 col-sm-8">
				<input type="password" class="input-text password" value="" placeholder="" id="repassword" name="repassword">
			</div>
			<i class="Hui-iconfont">&#xe725;</i>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别：</label>
			<div class="formControls col-xs-7 col-sm-8 skin-minimal">
				<span class="select-box">
					<select id="sex" name="sex" class="select">
						<option value="">请选择</option>
						<option value="0">男</option>
						<option value="1">女</option>
					</select>
				</span>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>年龄：</label>
			<div class="formControls col-xs-7 col-sm-8">
				<input type="number" min="0" class="input-text" value="0" placeholder="" id="age" name="age">
				<span>岁</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户权限：</label>
			<div class="formControls col-xs-7 col-sm-8 skin-minimal">
				<span class="select-box">
					<select id="user_auth" name="user_auth" class="select">
						{volist name="user_auth" id="vo"}
						<option value="{$vo.id}">{$vo.title}</option>
						{/volist}
					</select>
				</span>
			</div>
		</div>

		<div class="row cl">
			<div class="col-xs-7 col-sm-8 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn6 btn-primary size-M radius" type="submit" value="提交">
				<button onClick="parent.layer.close(parent.layer.getFrameIndex(window.name));" class="btn btn6 size-M radius" type="button">取消</button>
			</div>
		</div>
	</form>
</article>


<!--_footer 作为公共模版分离出去-->
{include file="public/_footer"}


<script>
	/*密码隐藏和显现*/
	var aInp = document.getElementsByClassName("password");
	var aI = document.getElementsByTagName("i");

	for(var i=0;i<aInp.length;i++){
		aInp[i].index = i;
		aInp[i].onkeydown = function () {
			aI[this.index].style.display = "block";
		}
	}
	for(var j=0;j<aI.length;j++){
		aI[j].index = j;
		oldtype = aInp[j].type;
		aI[j].onmousedown = function () {
			aInp[this.index].setAttribute('type', 'text');
		};
		aI[j].onmouseup = function () {
			aInp[this.index].setAttribute('type', oldtype);
		}
	}

</script>
<script type="text/javascript">
	imgUpload({
		inputId:'file', //input框id
		imgBox:'imgBox', //图片容器id
		date:"user_images"
	});
	
</script>
<script type="text/javascript">

    $(function(){
		$('.skin-minimal input').iCheck({
			checkboxClass: 'icheckbox-blue',
			radioClass: 'iradio-blue',
			increaseArea: '20%'
		});

		/*用户新增*/
		$("#form-member-add").validate({
			rules:{
					username:{
					required:true,
					minlength:2,
					maxlength:16
				},
				tel:{
					required:true,
					isMobile:true
				},
				email:{
					required:true,
					email:true
				},
				password:{
					required:true,
					minlength:5,
					maxlength:16
				},
				repassword:{
					required:true,
					minlength:5,
					maxlength:16,
					equalTo: "#password"
				},
				uploadfile:{
					required:true
				}
			},
			onkeyup:false,
			focusCleanup:true,
			success:"valid",
			submitHandler:function(form){
				var data = $(form).serializeArray();
				$(form).ajaxSubmit({
					type: 'post',
					url: "{:url('member/add_member')}",
					dataType: 'json',
					data: data,
					success: function(msg){
						if(msg.status == true){
							layer.msg(msg.message,{icon: 6,time:1000});
							setTimeout(jump,1000);
							function jump(){
								parent.location.reload();
							}
						}else if(msg.status == false){
							layer.msg(msg.message,{icon: 5,time:2000});
						}
					}
				});
			}
		});
	});


</script> 
